package vo
{
	import mx.formatters.NumberFormatter;
	
	[Bindable]
	public class EnglishLength
	{
		public var inch:Number;
		
		public function EnglishLength(cm:Number) {
			if (!isNaN(cm) && cm != 0) {
				inch = Math.floor(cm / 2.54);
				var remain:Number = cm / 2.54 - inch;
				if (remain < 0.0625) {
					remain = 0;
				} else if (remain < 0.1875) {
					remain = 0.125;
				} else if (remain < 0.3125) {
					remain = 0.25;
				} else if (remain < 0.4375) {
					remain = 0.375;
				} else if (remain < 0.5625) {
					remain = 0.5;
				} else if (remain < 0.6875) {
					remain = 0.625;
				} else if (remain < 0.8125) {
					remain = 0.75;
				} else if (remain < 0.9375) {
					remain = 0.875;
				} else {
					inch = inch + 1;
					remain = 0;
				}
				inch = inch + remain;
			}
		}

		public function toString():String {
			return inch + " inch";
		}
	}
}